import java.util.ArrayList;
import java.util.List;

/**
 * 1551. 使数组中所有元素相等的最小操作数
 * https://leetcode-cn.com/problems/minimum-operations-to-make-array-equal/
 */
public class Solutions_1551 {
    public static void main(String[] args) {
        int n1 = 3;  // output: 2
        int n2 = 6;  // output: 9

        List<Integer> inputs = new ArrayList<>();
        inputs.add(n1);
        inputs.add(n2);

        for (int input : inputs) {
            int result = minOperations(input);
            System.out.println(result);
        }
    }

    public static int minOperations(int n) {
        int res = 0;
        // 步进为 2，所有数都向 n 靠拢
        for (int i = 1; i < n; i += 2) {
            // (n - i) 次操作后可使 i == n
            res += n - i;
        }
        return res;
    }
}
